package com.zhaopin.reg;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author yin.peide
 * @since 2023-06-13
 */
public class TestReg {
    public static void main(String[] args) {
        // 按指定模式在字符串查找
        String line = "1134475812,JH344758120R90500000000,7000400050000,\"500180000,500020000,500220000\",757,-,2,6000,8000";
        String pattern = "(?<=[\"]).*(?=[\"])";

        // 创建 Pattern 对象
        Pattern r = Pattern.compile(pattern);

        // 现在创建 matcher 对象
        Matcher m = r.matcher(line);
        if (m.find()) {
            String innerStr = m.group(0);
            String line1 = line.substring(0, line.indexOf(innerStr) -2);
            String line2 = line.substring(line.indexOf(innerStr) + innerStr.length() + 2,line.length());
            String line11 = line1.replaceAll(",", "\t");
            String line22 = line2.replaceAll(",","\t");
            System.out.println(line11);
            System.out.println(innerStr);
            System.out.println(line22);
            String endStr = line11 + "\t" + innerStr + "\t" + line22;
            System.out.println(endStr);
        } else {
            System.out.println("NO MATCH");
        }
    }
}
